#include <iostream>
#include <vector>
#include <unordered_map>

using namespace std;

string reorganizeString(string s) {
    int n = s.size();
    string ret(n, 0);
    unordered_map<char, int> hash;
    int maxCount = 0;
    char maxVal = 0;
    for (auto c : s)
    {
        if (maxCount < ++hash[c])
        {
            maxCount = hash[c];
            maxVal = c;
        }
    }

    if (maxCount > (n + 1) / 2)
        return string();

    int index = 0;
    for (int i = 0; i < maxCount; ++i)
    {
        ret[index] = maxVal;
        index += 2;
    }

    hash.erase(maxVal);
    for (auto [x, y] : hash)
    {
        for (int i = 0; i < y; ++i)
        {
            if (index >= n)
                index = 1;
            ret[index] = x;
            index += 2;
        }
    }

    return ret;
}

int main()
{

	return 0;
}